package cn.com.simple.learning.rabbitmq.mq.consumer;

import cn.com.simple.learning.core.constants.RabbitMQConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author Jianxing.Jia
 * @date 2022/5/22
 * @description 描述信息
 */
@Slf4j
// @Component
public class Consumer {

    @RabbitListener(queues = RabbitMQConstants.QUEUE)
    public void consume(Message message) {
        String m = new String(message.getBody());
        log.info("接收到消息，message：{}", m);
    }

    @RabbitListener(queues = RabbitMQConstants.DELAY_QUEUE)
    public void delayConsume(Message message) {
        String m = new String(message.getBody());
        log.info("接收到延迟消息，当前时间：{}，message：{}", LocalDateTime.now(), m);
    }

}
